package com.jiayang.hhotel.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.jiayang.hhotel.R;
import com.jiayang.hhotel.presenter.NewestStatisticsPresenter;
import com.jiayang.hhotel.view.RoundProgressBar;

import cn.droidlover.xdroidmvp.mvp.XActivity;

/**
 * Created by Administrator on 2017/5/25 0025.
 * 最新统计页面
 */

public class NewestStatisticsActivity extends XActivity<NewestStatisticsPresenter> {

    private RoundProgressBar barOne,barTwo,barThree,barFour;//第一到四个圆
    private TextView YOne,YTwo,YThree,YFour;//第一到四个圆的文字
    private TextView totalRoomCount,canLiveRoomCount;//总房数,住房数

    @Override
    public void initData(Bundle savedInstanceState) {
        initTitle(this,true,getString(R.string.new_eststatistics),R.color.orange_color,null,null);

        totalRoomCount = (TextView) findViewById(R.id.tv_total_room_count);
        canLiveRoomCount = (TextView) findViewById(R.id.tv_can_live_room);
        barOne = (RoundProgressBar) findViewById(R.id.rp_one);
        barTwo = (RoundProgressBar) findViewById(R.id.rp_two);
        barThree = (RoundProgressBar) findViewById(R.id.rp_three);
        barFour = (RoundProgressBar) findViewById(R.id.rp_four);
        YOne = (TextView) findViewById(R.id.tv_one);
        YTwo = (TextView) findViewById(R.id.tv_two);
        YThree = (TextView) findViewById(R.id.tv_three);
        YFour = (TextView) findViewById(R.id.tv_four);

        totalRoomCount.setText("总房数");
        YOne.setText("YOne");
        YTwo.setText("YTwo");
        YThree.setText("YThree");
        YFour.setText("YFour");
        canLiveRoomCount.setText("住房数");
        canLiveRoomCount.setVisibility(View.INVISIBLE);


        barOne.setMax(100);//此处应该设置总房数
        barTwo.setMax(100);//此处应该设置总房数
        barThree.setMax(100);//此处应该设置总房数
        barFour.setMax(100);//此处应该设置总房数
        showThread(barOne,40);
        showThread(barTwo,60);
        showThread(barThree,80);
        showThread(barFour,90);
    }

    private Thread thread;
    /**
     * 启用线程用于让进度条有动画效果
     */
    private void showThread(final RoundProgressBar bar, final int count){
        bar.setRoomCount(count);
        thread = new Thread(new Runnable() {
            @Override
            public void run() {
                for(int i = 0;i<count;i++){
                    bar.setProgress(i);
                    try {
                        Thread.sleep(15);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        thread.start();
    }

    @Override
    public int getLayoutId() {
        return R.layout.layout_newest_statistics;
    }

    @Override
    public NewestStatisticsPresenter newP() {
        return null;
    }
}
